<template>
  <div class="paddingTop search_page">
    <head-top head-title="动态管理" goBack="true"></head-top>
    
    <input
      type="hidden"
      style="width: 12rem;height:1.5rem; font-size: 0.8rem;margin-top:0.5rem"
      placeholder="输入客户名称"
      v-model="createPerson"
    />



    <!--评论区 -->
    <div class="pl" v-for="item in dynamics" :key="item.id" style="margin-top:2rem">
      <li></li>
      <h5 class="shop_title ellipsis" style="margin-left:1.2rem;margin-top:-1.2rem">{{item.title}}</h5>
      <el-button
        type="danger"
        icon="el-icon-delete"
        circle
        style="float:right;margin-right:2rem;margin-top:-1rem;transform:scale(1.5)"
        @click="Delete(item.id)"
      ></el-button>
      <span style="font-size:0.7rem;margin-left:3.5rem">{{item.content}}</span>

      <br />
      <span
        class="order_time"
        style="font-size:0.6rem;margin-left:0.8rem;color:gray;margin-top:1rem"
      >{{item.createTime}}</span>
      <br />
    </div>
  </div>
</template>

<script>
import headTop from "../../components/header/head";
import footGuide from "../../components/footer/footGuide";
import { searchRestaurant } from "../../service/getData";
import { imgBaseUrl } from "../../config/env";
import { getStore, setStore } from "../../config/mUtils";
export default {
  data() {
    return {
      id:sessionStorage.getItem("userId"),
      dynamics: [],
      createPerson: "",
    };
  },
  created: function () {
    this.userId(this.id);
  
  },
  methods: {
    userId(id) {
      console.log(id);
      var vm = this;
      console.log(vm.id);
      this.axios({
        method: "get",
        url: "http://172.16.9.12:8081/getUserById",
        params: {
          userId: this.id,
        },
      }).then(function (res) {
        console.log(res.data);
        vm.createPerson = res.data;

        vm.axios({
        methods: "post",
        params: {
          createPerson: vm.createPerson,
        },
        url: "http://172.16.9.12:8081/house/dynamic/selectDynamicByPerson",
      }).then(function (res) {
        console.log(res);
        vm.dynamics = res.data.data.dynamics;
      });
      });
    },
  
    Delete(id) {
      var vm = this;

      this.axios({
        method: "post",
        url: `http://172.16.9.12:8081/house/dynamic/deleteDynamic/${id}`,
      }).then(function (res) {
        if (res.data.code == 200) {
          vm.$router.go(0);
          //弹出成功提示
          vm.$message({
            message: res.data.message,
            type: "success",
          });
        }
      });
    },
  },

  components: {
    headTop,
  },
};
</script>

<style>
.pl {
  margin-top: 2rem;
  height: 4rem;
  border-bottom: 2px solid lightgray;
}
</style>